﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FileApps.Properties;
using System.IO;

namespace FileApps.Utilities
{
    public static class FolderHelper
    {
        public static string GetDefaultFolder()
        {
            string defaultFolder;
            try
            {
                var recentFolder = Settings.Default.RecentFolder;
                defaultFolder = (string.IsNullOrEmpty(recentFolder)) || !Directory.Exists(recentFolder) ? Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) : recentFolder;

            }
            catch (NullReferenceException nre)
            {
                defaultFolder = Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments);
            }
            return defaultFolder;
        }

        public static void SaveDefaultFolder(string folder)
        {
            Settings.Default.RecentFolder = folder;
            Settings.Default.Save();
        }
    }

     
}
